home *** CD-ROM | disk | FTP | other *** search
- ///////////////////////////////////////////////////////////////
- //
- // Module : CUSTYPFN.PRG
- //
- // Created by SUMMER'93 (c) on Fri Nov 26 14:51:17 1993
- //
- ///////////////////////////////////////////////////////////////
- #include "snj.ch"
- // The following statics were declared 'PUBLIC' in the S87 code
- // OR were private and inherited by called functions
- // If they are used outside this module there will be a set/get
- // function with the same name as the var in this module
- static CTFLDS [ 2 ], CTHDRS [ 2 ]
- procedure CTEDIT( top, left, NROWS, MODE ) // Amended by SUMMER93
- // Calls:
- // Called By: HOUSEMAIN VCUSTTYP
- // C T E D I T
- // Routine to process Customer Classifications
- // Last change: MIB 26 Oct 93 5:51 pm
-
- local CTFUNC, OLDSCR, WIDTH
- // do CTEDIT with TOP, LEFT, NROWS, MODE
-
-
- save screen to OLDSCR
- select 0
- use CUSTTYPE alias CUSTTYPE
- WIDTH := 40
- CTFUNC := iif( MODE = 0, "CTSLCT", "CTUPDATE" )
-
- CTHDRS[ 1 ] := "Code"
- CTFLDS[ 1 ] := "CUSTTYPE"
- CTHDRS[ 2 ] := "Description"
- CTFLDS[ 2 ] := "CUSTDESC"
- set deleted on
- @ top, left, top + NROWS - 1, left + WIDTH box replicate( chr(177 ), 9 )
- @ top + 1, left + 2 clear to top + NROWS - 2, left + WIDTH - 2
- select CUSTTYPE
- go top
- set color to( COLBRIGHT() )
- do while !GETOUT()
- dbedit( top + 1, left + 2, top + NROWS - 2, left + WIDTH - 2, CTFLDS, ;
- CTFUNC, .t., CTHDRS, chr(196 ), chr(179 ))
- enddo
-
- GETOUT( .f. )
- restore screen from OLDSCR
- select CUSTTYPE
- pack
- index on FIELD->CUSTTYPE to CUSTTYPE
- use
- return
-
- //**********************************************************************
-
- function CTSLCT( MODE, FLD_PTR ) // Amended by SUMMER93
- // Calls: QBYESNO CTPRMT2
- // Called By:
- // The following locals have been declared by Summer'93
- // ROWNO COLNO
- local CURREC, CURFLD, MEDSTR, ROWNO, COLNO
-
- CURREC := recno( )
- ROWNO := row( )
- COLNO := col( )
-
- QBKEY( lastkey( ) )
- clear typeahead
- do case
- case MODE < 4
- return 1
- case QBKEY() = 27 .or. QBKEY() = 3
-
- MCUSTTYP( "" )
- MCDESC( "" )
- GETOUT( .t. )
- return 0
- case QBKEY() = 13
- save screen
- CURFLD := CTFLDS[ FLD_PTR ]
- MEDSTR := FIELD->CUSTTYPE ->&CURFLD
- set color to( COLFLASH() )
- @ ROWNO, COLNO say MEDSTR
- if QBYESNO( "Select this Type? (Y/N)" ) = "Y"
- MCUSTTYP( FIELD->CUSTTYPE ->CUSTTYPE )
- MCDESC( FIELD->CUSTTYPE ->CUSTDESC )
- GETOUT( .t. )
- return 0
- endif
- set color to( COLBRIGHT() )
- restore screen
- otherwise
- clear typeahead
- do CTPRMT2
- return 1
- endcase
-
- return 0
- //**********************************************************************
-
- function CTUPDATE( MODE, FLD_PTR ) // Amended by SUMMER93
- // Calls: CTPRMT1 QBYESNO QBPROMPT QBREAD
- // Called By:
- // The following locals have been declared by Summer'93
- // ROWNO COLNO ACTION PICSTR
- local SCRBOT, CURREC, GO_REC, CURFLD, MEDSTR, GETLIST, ROWNO, COLNO, ACTION;
- , PICSTR
- GETLIST := {}
-
- CURREC := recno( )
- ROWNO := row( )
- COLNO := col( )
-
- do CTPRMT1
- QBKEY( lastkey( ) )
- if QBKEY() = 27
- GETOUT( .t. )
- endif
-
- do case
- case( MODE = 2 .or. MODE = 3 ) // Past top or bottom
- if QBYESNO( "Add new Customer Type?" ) = "Y"
- QBRESP( "E" )
- go bottom
- append blank
- ROWNO := ROWNO + 1
- else
- do CTPRMT1
- return 1
- endif
- case MODE < 4
- return 1
- case QBKEY() = 13
- save screen
- CURFLD := CTFLDS[ FLD_PTR ]
- MEDSTR := FIELD->CUSTTYPE ->&CURFLD
- set color to( COLFLASH() )
- @ ROWNO, COLNO say MEDSTR
- QBRESP( iif( QBYESNO("Edit this line?" ) = "Y", "E", "I" ) )
- set color to( COLBRIGHT() )
- restore screen
- case QBKEY() = - 9 // F10
- ACTION := QBPROMPT( "Ignore|Edit|Delete|Restore deletions|Quit|", "", ;
- 2 )
- case QBKEY() = 27
- QBRESP( "Q" )
- otherwise
- QBRESP( "E" )
- keyboard chr( QBKEY() )
- endcase
-
- CURFLD := CTFLDS[ FLD_PTR ]
- MEDSTR := FIELD->CUSTTYPE ->&CURFLD
-
- do case
- case QBRESP() = "E" // Normal Selection by CR
- PICSTR := iif( len(MEDSTR )< 10, replicate("!", len(MEDSTR )), ;
- replicate("X", len(MEDSTR )))
-
- @ ROWNO, COLNO get MEDSTR picture PICSTR
- do QBREAD with "Enter Information" , , GETLIST
- // Call amended
- if CHANGED() .and. !GETOUT()
- replace &CURFLD with MEDSTR
- endif
- case QBRESP() = "Q"
- GETOUT( ( QBYESNO("Finished editing Customer types?" ) = "Y" ) )
- case QBRESP() = "D"
- save screen
- set color to( COLFLASH() )
- @ ROWNO, COLNO say MEDSTR
- if QBYESNO( "Delete this Customer type?" ) = "Y"
- delete
- endif
- set color to( COLBRIGHT() )
- restore screen
- do CTPRMT1
- skip - 1
- skip
- return 2
- case QBRESP() = "R"
- set deleted off
- recall all for deleted( )
- set deleted on
- do CTPRMT1
- return 2
- otherwise
- GETOUT( .f. )
- endcase
-
- keyboard iif( FLD_PTR = 1, chr(4 ), chr(19 ))
- set color to( COLBRIGHT() )
-
- return iif( GETOUT() , 0, 1 )
-
- //**********************************************************************
-
- procedure CTPRMT1
- // Calls: QBCLMESS
- // Called By: CTUPDATE
- // CTPRMT1
- local m
-
- do QBCLMESS
- set color to( COLBRIGHT() )
- m := "Move with " + chr( 24 ) + chr( 25 ) + ". Scroll PgUp/PgDn. Exit: ESC."
- @ QBMSGLIN() , centre( m, 80 )say m
- m := [Hit "F10" for Command: Edit, Delete, Restore, Quit]
- @ QBMSGLIN() + 1, centre( m, 80 )say m
-
- return
-
- //**********************************************************************
-
- procedure CTPRMT2
- // Calls: QBCLMESS
- // Called By: CTSLCT INVOWNGT IVFUNC
- // CTPRMT2
- local m
-
- do QBCLMESS
- set color to( COLBRIGHT() )
- m := "Move with " + chr( 24 ) + chr( 25 ) + ". Scroll PgUp/PgDn. " + chr( 17 );
- + chr( 217 ) + [ to Select, ESC to Abort]
- @ QBMSGLIN() , centre( m, 80 )say m
-
- return
-
- //**********************************************************************
-
- function VCUSTTYP( R, C, BLANKOK ) // Amended by SUMMER93
- // Calls: CTEDIT
- // Called By: REPARAM INVPAY
- // Return .t if Customer type is present or blank
- local RETVAL, MEM, VARNAME
-
-
- set softseek off
- VARNAME := readvar()
- // SUMMER93 - Caution
- // A call to 'readvar' followed by a macro can
- // be replaced by use of 'getactive' and 'varget'
- // VARNAME := GETACTIVE():VARGET()
- MEM := &VARNAME
- if empty( MEM ).and. BLANKOK
- MCUSTTYP( blank( MCUSTTYP() ) )
- MCDESC( blank( MCDESC() ) )
- return .t.
- endif
-
- select 0
- use CUSTTYPE index CUSTTYPE alias CUSTTYPE
-
- seek MEM
- if eof( )
- clear typeahead
- do CTEDIT with 3, 37, 9, 0
- MEM := iif( GETOUT() , blank(MEM ), MCUSTTYP() )
- else
- MEM := CUSTTYPE->CUSTTYPE
-
- MCUSTTYP( CUSTTYPE->CUSTTYPE )
- MCDESC( FIELD->CUSTTYPE ->CUSTDESC )
- endif
- set color to( COLBRIGHT() )
- @ R, C say MEM
- set color to( COLNORM() )
- use
-
- return .t.
-
- //*****************************************************************
-
- // End of file
-